package com.hxz.djbxkj.HxzExecutor.ExecutorComponent.Imp;

import com.hxz.djbxkj.HxzExecutor.ExecutorCode.Run.RunByHxzMethodImp;
import com.hxz.djbxkj.HxzExecutor.ExecutorComponent.ExecutorComponent;
import com.hxz.djbxkj.HxzExecutor.Model.JobMode;
import com.hxz.djbxkj.HxzExecutor.Model.TaskMode;
import com.hxz.djbxkj.HxzExecutor.zy.RunType;

public abstract class RunJkDoPlayTaskImp implements RunJk {
    @Override
    public TaskMode doPlay(TaskMode tm) {
        tm.setBegin();
        for(JobMode jm:tm.getJobModeS()){
            try {
                synchronized (tm){
                    ExecutorComponent.getThreadPoolExecutor().execute(new RunByHxzMethodImp(jm.getJob(),jm.getParameter(),jm.getId(),jm,jm.getAop()));
                }
            }catch (Exception e){
                jm.appendErrerMsg(e.getMessage());
                jm.appendErrerMsg(e.getLocalizedMessage());
                e.printStackTrace();
            }
        }
        if(tm.getSynchroniz()){
            return TaskMode.endTask(tm);
        }
        return tm;
    }
}
